<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core">
<h:head>
	<title>Income</title>
</h:head>
<ui:composition template="template">
	<ui:define name="content">
	    <h:dataTable id="infoIncome" value="#{incomeBean.incomeList}" var=i">
			<h:column>
				<f:facet name="header">ID</f:facet>
				#{i.id}
			</h:column>
			<h:column>
				<f:facet name="header">Amount</f:facet>
				#{i.amount}
			</h:column>
			<h:column>
				<f:facet name="header">Reason</f:facet>
				#{i.reason}
			</h:column>
			<h:column>
				<f:facet name="header">Category</f:facet>
				#{i.category}
			</h:column>
			<h:column>
				<f:facet name="header">Date</f:facet>
				#{i.date}
			</h:column>
		</h:dataTable>
		<h:form prependId="false">
			<h:panelGroup>
				<h:outputLabel for="amountTxt" value="Amount: "/>
				<h:inputText id="amountTxt" value="#{incomeBean.income.amount}" required="true" label="Amount"/>
				<h:message for="amountTxt" showSummary="false" errorStyle="color:red"/>
				<h:outputLabel for="reasonTxt" value="Reason: "/>
				<h:inputText id="reasonTxt" value="#{incomeBean.income.reason}" label="Reason"/>
				<h:outputLabel for="category" value="Category: "/>
				<h:selectOneMenu id="category" value="#{incomeBean.categoryId}">
					<f:selectItem value="#{null}" itemLabel="--------------" itemValue="#{null}"/>
					<f:selectItems value="#{categoryBean.categoryList}" var="c" itemLabel="#{c.name}" itemValue="#{c.id}"/>
				</h:selectOneMenu>
				<h:outputLabel for="dateTxt" value="Date: "/>
				<h:inputText id="dateTxt" value="#{incomeBean.income.date}"/>
				<h:commandButton value="Save" actionListener="#{incomeBean.saveIncome}">
					<f:ajax execute="@form" render="infoIncome"/>
				</h:commandButton>
			</h:panelGroup>			
		</h:form>
	</ui:define>
</ui:composition>
</html>